package com.rent.bean;

public class User {
	
	private int uid;
	private String uname;
	private String upassword;
	private int power;//权限
	private String idname;
	private String idcard;
	private String phonenumber;
	private double balance;
	private int confirminfo;
	private int rentCount;
	public Vip vip = new Vip();
	
	

	public User(int uid, String uname, String upassword, int power, String idname, String idcard, String phonenumber,
			double balance) {
		super();
		this.uid = uid;
		this.uname = uname;
		this.upassword = upassword;
		this.power = power;
		this.idname = idname;
		try {
			this.setIdcard(idcard);
		} catch (Exception e1) {
			e1.printStackTrace();
		}
		try {
			this.setPhonenumber(phonenumber);
		} catch (Exception e) {
			e.printStackTrace();
		}
		this.balance = balance;
	}

	public User(int uid, String uname, String upassword, int power, String idname, String idcard, String phonenumber,
			double balance, int confirminfo, int rentCount) {
		super();
		this.uid = uid;
		this.uname = uname;
		this.upassword = upassword;
		this.power = power;
		this.idname = idname;
		try {
			this.setIdcard(idcard);
		} catch (Exception e1) {
			e1.printStackTrace();
		}
		try {
			this.setPhonenumber(phonenumber);
		} catch (Exception e) {
			e.printStackTrace();
		}
		this.balance = balance;
		this.confirminfo = confirminfo;
		this.rentCount = rentCount;
	}

	public int getRentCount() {
		return rentCount;
	}

	public void setRentCount(int rentCount) {
		this.rentCount = rentCount;
	}

	public User(int uid, String uname, String upassword, int power, String idname, String idcard, String phonenumber,
			double balance, int confirminfo) {
		super();
		this.uid = uid;
		this.uname = uname;
		this.upassword = upassword;
		this.power = power;
		this.idname = idname;
		try {
			this.setIdcard(idcard);
		} catch (Exception e1) {
			e1.printStackTrace();
		}
		try {
			this.setPhonenumber(phonenumber);
		} catch (Exception e) {
			e.printStackTrace();
		}
		this.balance = balance;
		this.confirminfo = confirminfo;
	}

	public double getBalance() {
		return balance;
	}

	public void setBalance(double balance) {
		this.balance = balance;
	}

	public int getConfirminfo() {
		return confirminfo;
	}

	public void setConfirminfo(int confirminfo) {
		this.confirminfo = confirminfo;
	}

	private double money;
	public User() {}
	
	public User(String uname, double money) {
		super();
		this.uname = uname;
		this.money = money;
	}
	public User(int uid,String uname,String upassword,int power,String idname,String idcard,String phonenumber,int money) {
		this.uid=uid;
		this.uname=uname;
		this.power=power;
		this.upassword=upassword;
		this.idname=idname;
		try {
			this.setIdcard(idcard);
		} catch (Exception e1) {
			e1.printStackTrace();
		}
		try {
			this.setPhonenumber(phonenumber);
		} catch (Exception e) {
			e.printStackTrace();
		}
		this.money = money;
	}
	
	
	public int getUid() {
		return uid;
	}
	public void setUid(int uid) {
		this.uid = uid;
	}
	public String getUname() {
		return uname;
	}
	public void setUname(String uname) {
		this.uname = uname;
	}
	public String getUpassword() {
		return upassword;
	}
	public void setUpassword(String upassword) {
		this.upassword = upassword;
	}
	public int getPower() {
		return power;
	}
	public void setPower(int power) {
		this.power = power;
	}
	public String getIdname() {
		return idname;
	}
	public void setIdname(String idname) {
		this.idname = idname;
	}
	public String getIdcard() {
		return idcard;
	}
	public void setIdcard(String idcard) throws Exception {
		if(idcard.matches("^[1-9]\\d{5}(18|19|20|(3\\d))\\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$")) {
			this.idcard = idcard;			
		}else {
			throw new Exception("身份证号格式不正确");
		}
		
	}
	public String getPhonenumber() {
		return phonenumber;
	}
	public void setPhonenumber(String phonenumber) throws Exception {
		if(phonenumber.matches("^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$")) {
			this.phonenumber = phonenumber;
		}else {
			throw new Exception("电话号码格式不正确");
		}
		
	}

	public double getMoney() {
		return money;
	}

	public void setMoney(double money) {
		this.money = money;
	}
}
